package cn.chenc.framework.jpa.util;

import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

/**
 * 　@description: TODO
 * 　@author secret
 * 　@date 2021/6/5 23:08
 *
 */
public class PageableUtil {

    public PageableUtil() {
    }

    public static Pageable getPageDesc(int page, int size, String... properties) {
        return PageRequest.of(page > 0 ? page - 1 : 0, size, Sort.Direction.DESC, properties);
    }

    public static Pageable getPageAsc(int page, int size, String... properties) {
        return PageRequest.of(page > 0 ? page - 1 : 0, size, Sort.Direction.DESC, properties);
    }

}
